/**
 * @file       GBKSaxHandler.cc
 * @brief      
 * @author     LiuJkun
 * @version    1.0.0
 */

/*********************************************************************
 *  LiuJikun   01/28/10      Initial Version
 *********************************************************************/
#include	"GBKSaxHandler.h"

/******************************************************************************/

/// constructor
GBKSaxHandler::GBKSaxHandler( void ) {
} // GBKSaxHandler

/// destructor
GBKSaxHandler::~GBKSaxHandler( void ) {
} // ~GBKSaxHandler

/******************************************************************************/

void // called before reading document
GBKSaxHandler::startDocument( void ) {


} // GBKSaxHandler::startDocument

void // called for each object starting
GBKSaxHandler::startObject( Object* obj ) {
    String tag = obj->getString();
    printf ( "tag = %s\n", tag.c_str() );
    if ( tag == "doc" ) {
        m_elementType = ELEMENT_TYPE_DOC;
    } else if( tag == "title" ) {
        m_elementType = ELEMENT_TYPE_TITLE;
    } else if( tag == "docid" ) {
        m_elementType = ELEMENT_TYPE_DOCID;
    } else if( tag == "url" ) {
        m_elementType = ELEMENT_TYPE_URL;
    } else if( tag == "text" ) {
        m_elementType = ELEMENT_TYPE_TEXT;
    } else if( tag == "datestr" ) {
        m_elementType = ELEMENT_TYPE_DATE;
    } else {
        m_elementType = ELEMENT_TYPE_INVALID;
    }


} // GBKSaxHandler::startObject

/******************************************************************************/

void // called for each value in file
GBKSaxHandler::characters( Object* object ) {


} // GBKSaxHandler::characters

/******************************************************************************/

void // called for each object ending
GBKSaxHandler::endObject( Object* object ) {
    if ( m_elementType == ELEMENT_TYPE_TEXT ) {
        printf ( "------------------\n" );
    }
} // GBKSaxHandler::endObject

void // called after reading document
GBKSaxHandler::endDocument( void ) {


} // GBKSaxHandler::endDocument

/**
 * @brief 
 * @return
 */
void GBKSaxHandler::cdata ( Object *obj )
{
    String tag = obj->getString();
    if ( m_elementType == ELEMENT_TYPE_TITLE ) {
        printf ( "tag = %s\n", tag.c_str() );
    }
    return ;
}		

/******************************************************************************/



